var t = require;
var e = module;
var o = exports;
var n =
    (this && this.__extends) ||
    (function () {
        var t = function (e, o) {
            return (t =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) e.hasOwnProperty(o) && (t[o] = e[o]);
                })(e, o);
        };
        return function (e, o) {
            function n() {
                this.constructor = e;
            }
            t(e, o), (e.prototype = null === o ? Object.create(o) : ((n.prototype = o.prototype), new n()));
        };
    })();
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("fsm"),
    a = t("Util"),
    i = t("AIdelay"),
    s = t("AIMove"),
    c = t("AISkill"),
    l = t("AIStroll"),
    u = (function (t) {
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        return (
            n(e, t),
            (e.prototype.onEnter = function () {
                var t = this.context.search_enemy();
                if (t) this.has_target(t);
                else if (a.isRandom(0.3)) {
                    var e = this.context.search_build();
                    e ? this.has_target(e) : r.changeState(this.context, l.default);
                } else r.changeState(this.context, l.default);
            }),
            (e.prototype.has_target = function (t) {
                this.context.enemy.value = t;
                var e = this.context.skill.get_ready_skill();
                e
                    ? e.is_Can_Attack_Enemy(this.context, this.context.enemy.value)
                        ? r.changeState(this.context, c.default, {skill: e, enemy: this.context.enemy.value})
                        : r.changeState(this.context, s.default)
                    : r.changeState(this.context, i.default);
            }),
            e
        );
    })(t("bodyAI").default);
o.default = u;
